import java.util.Scanner;

public class MergeNum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[] num1 = new int[m+n];
        int[] num2 = new int[n];
        for (int i = 0; i < m+n; i++) {
            num1[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            num2[i] = sc.nextInt();
        }
        mergeNum(num1,num2,m,n);
    }
    public static void mergeNum(int[] num1,int[] num2,int m,int n) {
        //num1中没有元素
        if(m == 0) {
            for (int i = 0; i < n; i++) {
                System.out.print("["+num2[i]+"]");
            }
        }
        //num2中没有元素
        if(n == 0) {
            for (int i = 0; i < m; i++) {
                System.out.print("["+num1[i]+"]");
            }
        }
        //num1和num2都存在元素
        //首先将num2中的元素放到num1中
        for (int i = m; i < m+n; i++) {
            num1[i] = num2[i-m];
        }
        //对num1进行冒泡排序
        for (int i = 0; i < m+n; i++) {
            boolean flag = true;
            for (int j = 0; j < m+n-1; j++) {
                if(num1[j] > num1[j+1]) {
                    int tmp = num1[j];
                    num1[j] = num1[j+1];
                    num1[j+1] = tmp;
                    flag = false;
                }
            }
            if(flag == true) {
                break;
            }
        }
        for (int i = 0; i < m+n; i++) {
            System.out.print("["+num1[i]+"]");
        }
    }
}
